package com.example.javaow.mapper;/*
 * @Auther:Sadie
 * @Date:2025/8/12
 * @Description:
 * @VERSON:1.8
 */

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.javaow.domain.entity.DeviceGroup;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DeviceGroupMapper extends BaseMapper<DeviceGroup> {
    /**
     * 根据父ID和名称模糊查询
     */
    @Select("<script>" +
            "SELECT id, name, parent_id, description, status, createtime, updatetime " +
            "FROM device_group WHERE 1=1 " +
            "<if test='parentId != null'> AND parent_id = #{parentId} </if>" +
            "<if test='name != null and name != \"\"'> AND name LIKE CONCAT('%', #{name}, '%') </if>" +
            "</script>")
    List<DeviceGroup> selectByCondition(@Param("parentId") Long parentId, @Param("name") String name);
}
